Trying to use replace() method on files by passing the string not working - JS